package cc.dullsky.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

import cc.dullsky.common.model.User;

public class AuthInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		User user = controller.getSessionAttr("user");
		if (user == null) {
			controller.redirect("/login");
		} else {
			inv.invoke();
		}
	}

}
